
package combat.dudes.protocol.data;

import combat.dudes.protocol.interfaces.PhysicalObjectInt;
import combat.dudes.protocol.types.PhysicalObjectType;
import combat.dudes.server.protocol.implementation.NewID;


public class PhysicalObject extends NewID.ObjID implements PhysicalObjectInt {

	private static final long serialVersionUID = 1L;

	private PhysicalObjectType phyObjType = PhysicalObjectType.UNKNOWN;

	private int objID = -1;
	private String name = "";
	private DoublePoint position = null;
	private int altitude = 0;
	private double direction = 0.0;
	private double speed = 0.0;

	/**
	 * Constructor for making a new PhysicalObject, without parameters
	 */
	public PhysicalObject() {
		this.objID = getID();
	}

	public PhysicalObject(PhysicalObjectType phyObjType, String name, DoublePoint position,
			int altitude, double direction, double speed) {
		this.phyObjType = phyObjType;
		this.objID = getID();
		this.name = name;
		this.position = position;
		this.altitude = altitude;
		this.direction = direction;
		this.speed = speed;
	}
	public PhysicalObject(int objID, PhysicalObjectType phyObjType, String name, DoublePoint position,
			int altitude, double direction, double speed) {
		this.phyObjType = phyObjType;
		this.objID = getID();
		this.name = name;
		this.position = position;
		this.altitude = altitude;
		this.direction = direction;
		this.speed = speed;
	}

	@Override
	public PhysicalObjectType getType() {
		return (phyObjType == null) ? PhysicalObjectType.UNKNOWN : phyObjType;
	}
	@Override
	public void setType(PhysicalObjectType phyObjType) {
		this.phyObjType = phyObjType;
	}

	@Override
	public int getObjID() {
		return objID;
	}
	@Override
	public void setObjID(int objID) {
		this.objID = objID;
	}

	@Override
	public String getName() {
		return name;
	}
	@Override
	public void setName(String name) {
		this.name = name;
	}

	@Override
	public DoublePoint getPosition() {
		return (position == null) ? new DoublePoint() : position;
	}
	@Override
	public void setPosition(DoublePoint position) {
		this.position = position;
	}

	// Gets the current altitude:
	// -1 = below sea level
	// 0 = on sea level
	@Override
	public int getAltitude() {
		return altitude;
	}
	@Override
	public void setAltitude(int altitude) {
		this.altitude = altitude;
	}

	@Override
	public double getDirection() {
		return direction;
	}
	@Override
	public void setDirection(double direction) {
		this.direction = direction;
	}

	@Override
	public double getSpeed() {
		return speed;
	}
	@Override
	public void setSpeed(double speed) {
		this.speed = speed;
	}
}
